package timing.ukulele.third.controller.msg;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import timing.ukulele.common.data.ResponseData;
import timing.ukulele.data.third.data.msg.ChannelAccountDTO;
import timing.ukulele.data.third.view.msg.ChannelAccountVO;
import timing.ukulele.third.persistent.msg.ChannelAccount;
import timing.ukulele.third.service.msg.ChannelAccountService;
import java.util.List;

/**
 * 渠道账号管理接口
 *
 * @author zh
 */
@RestController
@RequestMapping("/msg/channelAccount")
@Slf4j
public class ChannelAccountController {

    private final ChannelAccountService service;

    public ChannelAccountController(ChannelAccountService service) {
        this.service = service;
    }

    /**
     * /msg/channelAccount/addChannelAccount
     * @param dto
     * @return
     */
    @PostMapping("/addChannelAccount")
    @Operation(summary = "新增渠道账号")
    public ResponseData<Boolean> addChannelAccount(@RequestBody ChannelAccountDTO dto) {
        return ResponseData.success(service.addChannelAccount(dto));
    }

    /**
     * /msg/channelAccount/updateChannelAccount
     * @param dto
     * @return
     */
    @PutMapping("/updateChannelAccount")
    @Operation(summary = "修改渠道账号")
    public ResponseData<Boolean> updateChannelAccount(@RequestBody ChannelAccountDTO dto) {
        return ResponseData.success(service.updateChannelAccount(dto));
    }

    /**
     * /msg/channelAccount/deleteChannelAccount
     * @param id
     * @return
     */
    @DeleteMapping("/deleteChannelAccount")
    @Operation(summary = "删除渠道账号")
    public ResponseData<Boolean> deleteChannelAccount(@RequestParam("id") Long id) {
        return ResponseData.success(service.deleteChannelAccount(id));
    }

    /**
     * /msg/channelAccount/page
     * @param dto
     * @return
     */
    @GetMapping("/page")
    @Operation(summary = "渠道账号分页列表")
    public ResponseData<IPage<ChannelAccountVO>> page(ChannelAccountDTO dto) {
        return ResponseData.success(service.pageList(dto));
    }

    /**
     * /msg/channelAccount/findListByChannelType
     * @return
     */
    @GetMapping("findListBySendChannel")
    @Operation(summary = "根据渠道获取账号列表")
    public ResponseData<List<ChannelAccount>> findListByChannelType(Integer sendChannel) {
        return ResponseData.success(service.findListBySendChannel(sendChannel));
    }

    /**
     * /msg/channelAccount/getAllList
     * @return
     */
    @GetMapping("getAllList")
    @Operation(summary = "获取全部列表")
    public ResponseData<List<ChannelAccount>> getAllList() {
        return ResponseData.success(service.getAllList());
    }

}
